import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { EQFiltersDto } from './eq.dto';
import { BooleanNumber } from 'common/utils/data';
import { EvaluationModel } from '../evaluation/evaluation.model';
import { UserModel } from '../user/user.model';

@Entity('EQ', {
  synchronize: false,
}) // 品牌
export class EQModel extends BaseModel {
  @Column({
    comment: '当前数据uuid',
    type: 'uuid',
  })
  evaluationUuid: string;
  @ManyToOne(() => EvaluationModel, {
    createForeignKeyConstraints: false,
  })
  @JoinColumn({
    name: 'evaluation_uuid',
    referencedColumnName: 'uuid',
  })
  evaluation: EvaluationModel;
  
  @Column({
    comment: '当前数据组',
    type: 'varchar',
    length: 500,
  })
  dataGroup: string;

  @Column({
    comment: '当前数据名称',
    type: 'varchar',
    length: 500,
  })
  name: string;

  @Column({
    comment: '文件',
    type: 'json',
    default: [],
  })
  audioFiles: string[];

  @Column({
    comment: '滤波器',
    type: 'json',
    default: [],
  })
  filters: EQFiltersDto[];

  @Column({
    comment: '用户',
    type: 'uuid',
  })
  userUuid: string;
  @ManyToOne(() => UserModel,{
    createForeignKeyConstraints: false,
  })
  @JoinColumn({
    name: 'user_uuid',
    referencedColumnName: 'uuid',
  })
  user: UserModel;

  @Column({
    comment: '是否公开',
    type: 'smallint',
    default: BooleanNumber.false,
  })
  open: BooleanNumber;

  @Column({
    comment: '描述',
    type: 'varchar',
    length: 500,
    default: '',
  })
  desc: string;
}
